<template>
  <div style="padding-top:30px;">
    <Table size="large" stripe :columns="columns" :data="columns_data"></Table>
  </div>
</template>

<script>
  import expandRow from './expand-row.vue';
  import jobApi from '../api/axios/jobApi'


  export default {
    components: { expandRow },
    data () {
      return {
        columns: [
          {
            type: 'expand',
            width: 50,
            render: (h, params) => {
              return h(expandRow, {
                props: {
                  row: params.row
                }
              })
            }
          },
          {
            title: '职位名称',
            key: 'jobName'
          },
          {
            title: '职位类型',
            key: 'jobType'
          },
          {
            title: '部门',
            key: 'section'
          },
          {
            title: '地点',
            key: 'city'
          },
          {
            title: '招聘人数',
            key: 'requireNum'
          },
          {
            title: '发布时间',
            key: 'createTime'
          }
        ],
        columns_data: []
      }
    },
    methods :{
      updateJobList() {
        let that = this;
        jobApi.getJobList({
          recruit_type: '实习生'
        },{
          success (res) {
            if (res.data.status === 200) {
              that.columns_data = res.data.data.map(function(item,index){
                item.createTime = that.formatDate(item.createTime);
                return item;
              });
            }else {
              console.log("getJobList 请求失败：" + res.data);
            }
          }
        });
      },
      formatDate(times){
        let daytime = new Date(times);
        return daytime.getFullYear()+"-"+(daytime.getMonth()+1)+"-"+daytime.getDate();
      }
    },
    created() {
      this.updateJobList();
    }
  }
</script>

<style>


</style>
